/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.gorkemozbek.rubic.util.struct

object asBoolean extends GenericView[Boolean] {

  def apply(in: Struct): Boolean = in match {
    case BooleanStruct(x) => x
    case NumericStruct(x) => x > 0
    case TextualStruct(x) => x.length > 0
    case SetStruct(x) => ! x.isEmpty
    case ListStruct(x) => ! x.isEmpty
    case TableStruct(x) => ! x.isEmpty
  }

}
